<?php
//==================================
//设置搜索条件，根据筛选框传递过来的数据，
//拼装sql语句
//==================================
//假删除的就不会显示
$_condition="(status != '已删除' or status is null)";

foreach ($_REQUEST as $k=>$v)
{



//提取like,需要注意，是否包含多个值得
if((substr($k,0,5)=="like_") and ( $v ))
{
$_item=substr($k,5);
$_item_list=explode("+",$_item);
//print_r2($_item_list);
if(count($_item_list)>1)
{
foreach ( $_item_list as $k2=>$v2)
{
$_like=$_like." or ".$v2." like '%".$v."%'" ;

}
$_like=substr($_like,3);
$_condition="(".$_like.")";

}
else
{
$_item=substr($k,5);
$_condition=$_condition." and ".$_item." like '%".$v."%'" ;
}
}



//提取euqal
if((substr($k,0,6)=="equal_") and ( $v ))
{
$_item=substr($k,6);
$_condition=$_condition." and ".$_item." = '".$v."'" ;
}




//提取 小于
if((substr($k,0,5)=="less_") and ( $v ))
{
$_item=substr($k,5);
$_condition=$_condition." and ".$_item." < '".$v."'" ;
}

//提取 大于
if((substr($k,0,8)=="greater_") and ( $v ))
{
$_item=substr($k,8);
$_condition=$_condition." and ".$_item." > '".$v ."'";
}

//提取 小于等于
    if((substr($k,0,5)=="lessequal_") and ( $v ))
    {
        $_item=substr($k,5);
        $_condition=$_condition." and ".$_item." <= '".$v."'" ;
    }

//提取 大于等于
    if((substr($k,0,8)=="greaterequal_") and ( $v ))
    {
        $_item=substr($k,8);
        $_condition=$_condition." and ".$_item." >= '".$v ."'";
    }
    }





//
////如果接受到brand，就把所属全部找出来
//
//if($_REQUEST['product'])
//{
//
//    $_product_list=select_lines_all_items($table_prefix."relation","nid desc","term_nid = '{$_REQUEST['brand']}'","");
//    $_product_nid_list=transform_2darray_in_1darray_number_as_key($_product_list,"detail_nid");
//    $_condition=$_condition." and nid in ('".implode("','",$_product_nid_list)."')";
//}



?>